home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / dynParticleValues.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.5 KB  |  332 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // dynParticleValues.mel 
  18. // This script fills the Dynamics particle tool property sheet with
  19. // values and sets the control callbacks.
  20. // property sheet.
  21. // The property sheet is set up in  dynParticleProperties.mel
  22. //
  23. global proc dynParticleGridMinCB (string $toolName, 
  24.                                   string $minControl, string $maxControl,
  25.                                   string $minFlag, string $maxFlag)
  26. {
  27.     global float $dynMaxFloatField;
  28.     global float $dynMinFloatField;
  29.  
  30.     dynFloatMinMax ($toolName, " dynParticleCtx",  $minControl, 
  31.                     $minFlag, $dynMinFloatField, $dynMaxFloatField);
  32.  
  33.     // If the user sets the min greater than max, reset max to be 
  34.     // the same as min;
  35.     //
  36.     float $min = `floatSliderGrp -q -v  $minControl`;
  37.     float $max = `floatSliderGrp -q -v  $maxControl`;
  38.  
  39.     if ($min > $max)
  40.     {
  41.         floatSliderGrp -e -v $min $maxControl;
  42.         dynFloatMinMax ($toolName, " dynParticleCtx", $maxControl,
  43.                          $maxFlag, $dynMinFloatField, $dynMaxFloatField);
  44.     }
  45. }
  46.  
  47.  
  48. global proc dynParticleGridMaxCB (string $toolName, 
  49.                                   string $minControl, string $maxControl,
  50.                                   string $minFlag, string $maxFlag)
  51. {
  52.     global float $dynMaxFloatField;
  53.     global float $dynMinFloatField;
  54.  
  55.     dynFloatMinMax ($toolName, " dynParticleCtx",  $maxControl, 
  56.                     $maxFlag, $dynMinFloatField, $dynMaxFloatField);
  57.  
  58.     // If the user sets max less than min, reset min to be the
  59.     // same as max;
  60.     //
  61.     float $min = `floatSliderGrp -q -v  $minControl`;
  62.     float $max = `floatSliderGrp -q -v  $maxControl`;
  63.  
  64.     if ($min > $max)
  65.     {
  66.         floatSliderGrp -e -v $max $minControl;
  67.         dynFloatMinMax ($toolName, " dynParticleCtx", $minControl,
  68.                          $minFlag, $dynMinFloatField, $dynMaxFloatField);
  69.     }
  70. }
  71.  
  72.  
  73. global proc dynDimSketch(int $isSketchOn)
  74. {
  75.  
  76.     // Dim or undim the widgets connected with particle sketch
  77.     //
  78.     if ($isSketchOn)
  79.     {
  80.         intSliderGrp -e -enable true sketchInterval;
  81.         checkBoxGrp -e -v1 off particleGrid;
  82.         checkBoxGrp -e -v1 on particleSketch;
  83.     }
  84.     else
  85.     {
  86.         intSliderGrp -e -enable false sketchInterval;
  87.         checkBoxGrp -e -v1 off particleSketch;
  88.     }
  89. }
  90.  
  91. global proc dynEnableGridPositions(int $enable)
  92. {
  93.     // Show or hide the widgets connected with particle grid.
  94.     //
  95.     floatSliderGrp -edit -enable $enable pGridLLX;
  96.     floatSliderGrp -edit -enable $enable pGridLLY;
  97.     floatSliderGrp -edit -enable $enable pGridLLZ;
  98.  
  99.     floatSliderGrp -edit -enable $enable pGridURX;
  100.     floatSliderGrp -edit -enable $enable pGridURY;
  101.     floatSliderGrp -edit -enable $enable pGridURZ;
  102. }
  103.  
  104. global proc dynDimGrid(string $toolName, int $isGridOn)
  105. {
  106.  
  107.     // Dim or undim the widgets connected with particle grid
  108.     //
  109.     if ($isGridOn)
  110.     {
  111.         floatSliderGrp -e -enable 1 pGridSpacing;
  112.         intSliderGrp -e -enable 0 pNumJitters;
  113.         floatSliderGrp -e -enable 0 pJitterRadius;
  114.         checkBoxGrp -e -v1 off particleSketch;
  115.         checkBoxGrp -e -v1 on particleGrid;
  116.         radioButtonGrp -e -enable true pGridPlacement1;
  117.         radioButtonGrp -e -enable true pGridPlacement2;
  118.  
  119.         if (`dynParticleCtx -q -cp $toolName`)
  120.         {
  121.             radioButtonGrp -e -sl 1 pGridPlacement1;
  122.             dynEnableGridPositions(0);
  123.         }
  124.         else
  125.         {
  126.             radioButtonGrp -e -sl 1 pGridPlacement2;
  127.             dynEnableGridPositions(1);
  128.         }
  129.     }
  130.     else
  131.     {
  132.         floatSliderGrp -e -enable false pGridSpacing;
  133.         intSliderGrp -e -enable true pNumJitters;
  134.         checkBoxGrp -e -v1 off particleGrid;
  135.         if (`intSliderGrp -q -v pNumJitters` <= 1) {
  136.             floatSliderGrp -e -enable false pJitterRadius;
  137.         } else {
  138.             floatSliderGrp -e -enable true pJitterRadius;
  139.         }
  140.         radioButtonGrp -e -enable false pGridPlacement1;
  141.         radioButtonGrp -e -enable false pGridPlacement2;
  142.         dynEnableGridPositions(0);
  143.     }
  144. }
  145.  
  146. global proc dynSketchCB(string $toolName, int $isSketchOn)
  147. {
  148.  
  149.     // Let the context know the change in state of the
  150.     // Sketch checkbox, and activate/dim necessary widgets.
  151.  
  152.     dynParticleCtx -e -sk $isSketchOn $toolName;
  153.  
  154.     dynDimSketch($isSketchOn);
  155. }
  156.  
  157. global proc dynGridCB(string $toolName, int $isGridOn)
  158. {
  159.  
  160.     // Let the context know the change in state of the
  161.     // grid checkbox, and activate/dim necessary widgets.
  162.  
  163.     dynParticleCtx -e -gr $isGridOn $toolName;
  164.  
  165.     dynDimGrid($toolName, $isGridOn);
  166. }
  167.  
  168.  
  169. global proc dynParticleValues (string $toolName) 
  170. {
  171.     // These globals contain the lowest min and highest max for the
  172.     // dynamics float fields.
  173.     //
  174.     global float $dynMaxFloatField;
  175.     global float $dynMinFloatField;
  176.  
  177.     // Set the top layout to be the current parent
  178.     //
  179.     string $parent = (`toolPropertyWindow -q -location` + "|dynParticle");
  180.     setParent $parent;
  181.  
  182.     string $helpTag = "Particle";
  183.     toolPropertySetCommon $toolName "particle.xpm" $helpTag;
  184.  
  185.     // Get the values from the context and put them into the contols.
  186.     //
  187.     textFieldGrp -e 
  188.         -tx `dynParticleCtx -q -pn $toolName` 
  189.         -cc ("dynParticleCtx -e -pn \"#1\" "+$toolName)
  190.         particleName;
  191.  
  192.     floatSliderGrp -e
  193.         -v `dynParticleCtx -q -c $toolName`
  194.         -cc ("dynParticleCtx -e -c #1 "+$toolName)
  195.         particleConserve;
  196.  
  197.     intSliderGrp -e 
  198.         -v `dynParticleCtx -q -nj $toolName` 
  199.         -cc ("dynIntMinMax "+$toolName+" dynParticleCtx pNumJitters -nj 0 "+$dynMaxFloatField)
  200.         pNumJitters;
  201.  
  202.     if (`intSliderGrp -q -v pNumJitters` == 0) 
  203.     {
  204.         checkBoxGrp -e -enable false particleSketch;
  205.         intSliderGrp -e -enable false sketchInterval;
  206.         checkBoxGrp -e -enable false particleGrid;
  207.     }
  208.     else
  209.     {
  210.         checkBoxGrp -e -enable true particleSketch;
  211.         checkBoxGrp -e -enable true particleGrid;
  212.     }
  213.  
  214.     if (`intSliderGrp -q -v pNumJitters` <= 1) {
  215.         floatSliderGrp -e 
  216.             -v `dynParticleCtx -q -jr $toolName` 
  217.             -cc ("dynFloatMinMax " +
  218.                     $toolName +
  219.                     " dynParticleCtx pJitterRadius -jr 0 " +
  220.                     $dynMaxFloatField)
  221.             -enable false
  222.             pJitterRadius;
  223.     } else {
  224.         floatSliderGrp -e 
  225.             -v `dynParticleCtx -q -jr $toolName` 
  226.             -cc ("dynFloatMinMax " +
  227.                     $toolName +
  228.                     " dynParticleCtx pJitterRadius -jr 0 " +
  229.                     $dynMaxFloatField)
  230.             -enable true
  231.             pJitterRadius;
  232.     }
  233.  
  234.     checkBoxGrp -e
  235.         -on1 ("dynSketchCB "+$toolName+" 1")
  236.         -of1 ("dynSketchCB "+$toolName+" 0")
  237.         particleSketch;
  238.  
  239.     if (`dynParticleCtx -q -sk $toolName`) 
  240.     {
  241.         dynDimSketch(1);
  242.     }
  243.     else
  244.     {
  245.         dynDimSketch(0);
  246.     }
  247.  
  248.     intSliderGrp -e 
  249.         -v `dynParticleCtx -q -ski $toolName` 
  250.         -cc ("dynIntMinMax "+$toolName+" dynParticleCtx sketchInterval -ski 0 "+$dynMaxFloatField)
  251.         sketchInterval;
  252.  
  253.     checkBoxGrp -e
  254.         -on1 ("dynGridCB "+$toolName+" 1")
  255.         -of1 ("dynGridCB "+$toolName+" 0")
  256.         particleGrid;
  257.  
  258.     if (`dynParticleCtx -q -gr $toolName`) 
  259.     {
  260.         dynDimGrid($toolName, 1);
  261.     }
  262.     else
  263.     {
  264.         dynDimGrid($toolName, 0);
  265.     }
  266.  
  267.     floatSliderGrp -e 
  268.         -v `dynParticleCtx -q -grs $toolName` 
  269.         -cc ("dynFloatMinMax "+$toolName+" dynParticleCtx pGridSpacing -grs 0 "+$dynMaxFloatField)
  270.         pGridSpacing;
  271.  
  272.     radioButtonGrp -e
  273.         -on1 ("dynParticleCtx -e -cp "+$toolName+"; dynEnableGridPositions(0)")
  274.         pGridPlacement1;
  275.  
  276.     radioButtonGrp -e
  277.         -on1 ("dynParticleCtx -e -tp "+$toolName+"; dynEnableGridPositions(1)")
  278.         pGridPlacement2;
  279.  
  280.     if (`dynParticleCtx -q -cp $toolName`) 
  281.     {
  282.         radioButtonGrp -e -sl 1 pGridPlacement1;
  283.          dynEnableGridPositions(0);
  284.     }
  285.     else 
  286.     {
  287.         radioButtonGrp -e -sl 1 pGridPlacement2;
  288.         if(`dynParticleCtx -q -gr $toolName`) 
  289.         {
  290.             dynEnableGridPositions(1);
  291.         }
  292.         else 
  293.         {
  294.             dynEnableGridPositions(0);
  295.         }
  296.     }
  297.  
  298.     floatSliderGrp -e 
  299.         -v `dynParticleCtx -q -llx $toolName` 
  300.         -cc ("dynParticleGridMinCB "+$toolName+" pGridLLX pGridURX -llx -urx")
  301.         pGridLLX;
  302.  
  303.     floatSliderGrp -e 
  304.         -v `dynParticleCtx -q -lly $toolName` 
  305.         -cc ("dynParticleGridMinCB "+$toolName+" pGridLLY pGridURY -lly -ury")
  306.         pGridLLY;
  307.  
  308.     floatSliderGrp -e 
  309.         -v `dynParticleCtx -q -llz $toolName` 
  310.         -cc ("dynParticleGridMinCB "+$toolName+" pGridLLZ pGridURZ -llz -urz")
  311.         pGridLLZ;
  312.  
  313.     floatSliderGrp -e 
  314.         -v `dynParticleCtx -q -urx $toolName` 
  315.         -cc ("dynParticleGridMaxCB "+$toolName+" pGridLLX pGridURX -llx -urx")
  316.         pGridURX;
  317.  
  318.     floatSliderGrp -e 
  319.         -v `dynParticleCtx -q -ury $toolName` 
  320.         -cc ("dynParticleGridMaxCB "+$toolName+" pGridLLY pGridURY -lly -ury")
  321.         pGridURY;
  322.  
  323.     floatSliderGrp -e 
  324.         -v `dynParticleCtx -q -urz $toolName` 
  325.         -cc ("dynParticleGridMaxCB "+$toolName+" pGridLLZ pGridURZ -llz -urz")
  326.         pGridURZ;
  327.  
  328.     toolPropertySelect dynParticle;
  329. }
  330.  
  331.  
  332.